package sctu.edu.java.year2016.team06.chenqiang.day20160601.chapter10_2;

/**
 * Created by XQ on 2016/6/1.
 * 分别向Set集合以及List集合中添加 “A”、“a”、“c”、"C"、“a”五个元素，
 *  观察重复值 “a”能否在List集合以及Set中成功添加。
 */
import java.util.*;
public class Add {
    public static void main(String[] args) {
        String[] a={"A","a","c","C","a"};
        List<String> list=new LinkedList<String>();
        for(int i=0;i< a.length;i++){
            list.add(a[i]);
        }
        System.out.println("The list of object in the collection is:"+list);
        Set<String> set=new HashSet<String>();
        for(int i=0;i< a.length;i++){
            set.add(a[i]);
        }
        Iterator<String> it=set.iterator();
        System.out.println("The set of object in the collection is:");
        while(it.hasNext()){
            System.out.print(it.next() + " ");
        }
    }
}
